Skip to content

Pull-many support + vectors as query values#39

Merged
mpdairy merged 6 commits intompdairy:masterfrom
Quezion:pull-many-support
Oct 22, 2019
Merged

Pull-many support + vectors as query values#39
mpdairy merged 6 commits intompdairy:masterfrom
Quezion:pull-many-support

Conversation

@Quezion
Copy link
Copy Markdown
Contributor

@Quezion Quezion commented Oct 22, 2019

Adds support for pull-many in the Posh API. Includes a basic test included below to demonstrate usage.

(let [conn (dt/create-conn)
      _ (d/posh! conn)
      ents [{:a "foo" :b 42}
            {:a "bar" :b 52}
            {:a "baz" :b 62}]
      tran (d/transact! conn ents)
      eids (->> (d/q '[:find ?e
                       :where [?e :a _]] conn)
                deref
                (reduce into [])
                reverse)
      ;;dtlg-raw (dt/pull-many (dt/db conn) '[*] eids)
      entity-reaction (d/pull-many conn '[*] eids)]
  (is (= ents (map #(select-keys % [:a :b]) @entity-reaction))
      "Entities in reaction should match input entities against input sequence of eids")
  (let [updated-ents (vec (map #(update % :b inc) @entity-reaction))]
    (d/transact! conn updated-ents)
    (is (= updated-ents @entity-reaction)
        "Entities in reaction should updated after transact")))

I noticed that pull-many-analyze already existed, so my only change there was using Datomic's official pull-many function. I added similar functions to the existing pull in other namespaces & it "just worked", but there could certainly be problems with this implementation. Eyes are appreciated.

This PR also includes the "vector as value" support & tests from PR #38 (which I've closed), but I can split these PRs back out if desired.

Fixes #37 , re-posh denistakeda/re-posh#32

Supports solution for denistakeda/re-posh#26

Dummy implementation for q-analyze/resolve-any-idents, works for
vector values but probably breaks caching for lookup refs
Assumed that lookup-refs are either eid in :where clause, or
if in value place, that schema has :db/valueType :db.type/ref
Simple tests on lookup refs & tuple queries in datascript_test.cljc
@denistakeda
Copy link
Copy Markdown

Hello @mpdairy . Are you still interested in support this repo?

@mpdairy mpdairy merged commit 413337f into mpdairy:master Oct 22, 2019
@mpdairy
Copy link
Copy Markdown
Owner

mpdairy commented Oct 22, 2019

No, I don't really want to support posh. Do you want to? If somebody wants to do a fork or new repo, I'll put a link to it at the top of the README to direct people there. Or I can give access to edit this repo.

@denistakeda
Copy link
Copy Markdown

@mpdairy posh is the critical component for my own re-posh library, which I want to support, so maybe I could support posh either. Let's go for the fork: https://github.com/denistakeda/posh

And thank you for your awesome library!

@mpdairy
Copy link
Copy Markdown
Owner

mpdairy commented Oct 22, 2019

Oh, cool! I didn't know you made re-posh. Well, the fork is in good hands, then. I added a link to your fork.

@mpdairy
Copy link
Copy Markdown
Owner

mpdairy commented Oct 23, 2019

@denistakeda is there a way I can hand over the clojars keys to you so you can take the posh name? it's been so long since I've used clojars...

@denistakeda
Copy link
Copy Markdown

@mpdairy not sure how to change access rights in clojar. But I've already created a new posh artifact.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support for tuple valueTypes

3 participants